#ifndef __APIDEMO_H__ 
#define __APIDEMO_H__

#include <curl/curl.h>

// 任务状态
enum {
    STATE_PENDING = 0,
    STATE_RUNNING = 1,
    STATE_WAITING = 2,
    STATE_ERRWAITING = 3,
    STATE_CANCELING = 4,
    STATE_FINISHED = 5,
    STATE_CANCELED = 6,
    STATE_ABORTED = 7
};

// 任务指令
enum {
    CMD_CANCEL = 2,
    CMD_VERIFY = 3
};


class JzAGVApi
{
public:
    JzAGVApi(std::string url);
    ~JzAGVApi();
public:
    std::string GetRobot(int robotID);
    std::string GetRobots();
    std::string CreateMission();
    std::string GetMission(int missionID);
    std::string GetMissionByUUID(std::string uuid);
    std::string CreateMissionCommand(int cmdType, int missionID, std::string missionUUID="", bool sync=false);
    std::string CheckMissionCommand(int cmdID);
public:
    std::string Get(const char *url);
    std::string Post(const char *url, const std::string &data);
public:
    static size_t CurlWriteCallback(char* buffer, size_t size, size_t nitems, void* userdata);
private:
    CURL* m_pHandle;
    std::string m_url;
};

#endif
